﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace SacMauVN
{
    public partial class UCLeftBody : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadListMenu();
            }
        }

        protected void LoadListMenu()
        {
            string sql = "SELECT ID,Ten,IsShowUp FROM tblSMVNMenu WHERE Level = 1";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            string category;
            int cID;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                category = dt.Rows[i]["Ten"].ToString();
                cID = Convert.ToInt32(dt.Rows[i]["ID"]);
                string sSql = "SELECT ID,Ten,IsShowUp FROM tblSMVNMenu WHERE ParentID = " + cID;
                DataTable data = SqlHelper.ExecuteDataTable(CommandType.Text, sSql);
                UCMenuBlock Lists = (UCMenuBlock)LoadControl("UCMenuBlock.ascx");
                Lists.LoadData(category, data);
                ltrMenuList.Controls.Add(Lists);
            }
        }
    }
}